HAVE_EET=$(shell pkg-config --exists eet 2>/dev/null && echo 'yes')
CFLAGS = -Wall -g

ifeq ($(HAVE_EET),yes)
CFLAGS += $(shell pkg-config --cflags eet)
LIBS += $(shell pkg-config --libs eet)
BINS = eetc
endif

LEX = flex
YACC = bison -y
YFLAGS = -d


all: $(BINS)

eetc_SRCS = \
eetc.c

eetc_OBJS = \
eetc_lexer.o \
eetc_grammar.o \
$(eetc_SRCS:.c=.o)

eetc_grammar.o: eetc_grammar.y
eetc_lexer.o: eetc_lexer.l eetc_grammar.c

eetc_lexer.c: eetc_lexer.l
	$(LEX) $(LFLAGS) -o $@ $^


eetc: $(eetc_OBJS)
	$(RM) $@
	$(CC) $(LIBS) $(CFLAGS) $(LDFLAGS) $(eetc_OBJS) -o $@

clean:
	rm -rf $(BINS) *.o *~ eetc_lexer.c eetc_grammar.c

